home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™94 / Talks & Papers / Timothy Knox / yerk 3.66 / tool+ / textEdit < prev    next >
Text File  |  1994-06-24  |  3KB  |  102 lines

  1. \ textEdit class based on bjr 1987
  2. \ 12.11.89    rfl now subclass of handle
  3. \ A lot of these methods leave the current font of the window changed.
  4. \ 4.17.91    rfl fixed rect1...actually should move into rect
  5. \ 4.23.91    rfl    added addText:
  6. \ 10.18.91    rfl    protect for 32k limit
  7. \ 2.22.94    rfl    added autoscroll
  8.  
  9. $ 7fff value teLimit
  10.  
  11. :CLASS TextEdit <Super handle
  12.  
  13.     Rect ViewRect        \ as in IM V1
  14.     Rect DestRect        \ ditto
  15.  
  16.   :M  PtIn: ( -- b) where: theMouse pack ptIn: viewrect ;M 
  17.   :M  TEString: ( addr len  -- AbsAddr Length) swap +Base swap ;M
  18.   
  19.   \ first set up rects
  20.   :M  New: { myWind  -- }
  21.         alive: myWind not classerr" 133
  22.         PushPort set: myWind
  23.         0 Abs: DestRect Abs: ViewRect Call TENew m!
  24.         PopPort ;M
  25.  
  26.   :M  alive: ( -- b) m@ 0 <> ;M
  27.   
  28.   :M  close: m@ -dup IF Call TEDispose 0 m! THEN ;M
  29.   
  30.   :M  justify: ( Just --) MakeInt m@ Call TESetJust ;M
  31.   
  32.   :M  SetSelect: ( Start End --) m@ Call TESetSelect ;M
  33.   
  34.   :M  HighLight: 0 1000 setSelect: self ;M
  35.  
  36.   :M  moveTo: ( Position --) Dup SetSelect: Self ;M
  37.   
  38.   :M  Activate: m@ Call TEActivate ;M
  39.   
  40.   :M  Deactivate: m@ Call TEDeactivate ;M
  41.  
  42.   :M  teCut: m@ Call TECut ;M
  43.   
  44.   :M  teCopy: m@ Call TECopy ;M
  45.   
  46.   :M  tePaste: m@ Call TEPaste ;M
  47.  
  48.   :M  teDelete: m@ Call TEDelete ;M
  49.  
  50.   :M  GetScrap: ( -- addr len) global TEScrpHandle @ >ptr global TEScrpLength w@ ;M
  51.  
  52.   :M  PutText: ( addr len --) TEString: Self m@ Call TESetText ;M
  53.   
  54.   :M  GetText: ( -- addr len)
  55.         0 m@ Call TEGetText >ptr ptr: self 60 + w@  ;M
  56.  
  57.   :M  ReCal: m@ call TECalText ;M
  58.  
  59.   :M  textSize: ( -- len) getText: self swap drop ;M
  60.   
  61.   :M  overLimit?: ( len -- len b) dup textSize: self + teLimit > ;M
  62.  
  63.   :M  clear: 0 textSize: self setSelect: self TEDelete: self ;M
  64.   
  65.   :M  Insert: ( addr len --) TEString: Self m@ Call TEInsert ;M
  66.   
  67.   :M  Key: ( char --) MakeInt m@ Call TEKey ;M
  68.   
  69. \ could change teDelete to TeCut to do something with top of text
  70. \ for right now, delete twice the new addition and creep up to top again
  71.   :M  AddText: ( addr len --) overLimit?: self
  72.         IF 0 over 2* setSelect: self teDelete: self
  73.         THEN
  74.         textSize: self 1+ moveto: self insert: self ;M
  75.  
  76.   :M  Draw: clear: destRect
  77.         Abs: destRect m@ Call TEUpdate ;M
  78.   
  79.   :M  print:  abs: destRect m@ call TEUpdate ;M
  80.   
  81.   :M  Scroll: ( dh dv--)    pack m@ Call TEScroll ;M
  82.   
  83.   :M  Click: where: themouse pack false Bool m@ Call TEClick ;M
  84.   
  85.   :M  Idle: m@ Call TEIdle ;M
  86.   
  87.   :M  PutRect: ( l t r b --) put: viewRect  get: viewRect put: destRect
  88.         m@ IF get: destRect ptr: self put: rect
  89.               get: viewRect ptr: self 8+ put: rect
  90.             THEN ;M
  91.  
  92.   :M  ChangeRect: get: destRect ptr: self put: rect get: viewRect ptr: self 8+ put: rect ;M
  93.   
  94.   :M  OffSet: { dx dy -- }
  95.         dx dy OffSet: viewRect get: viewRect put: destRect ;M
  96.   
  97.   :M  InsetDest: ( dx dy --) Inset: DestRect ;M
  98.  
  99.   :M  autoScroll: ( b --) bool m@ call teAutoView ;M
  100.  
  101. ;CLASS
  102.